<?php

/**
 *
 * @author Marc André Audet <root@manhim.net>
 * @copyright Copyright(c) 2009-2010 Marc André Audet
 * @license http://www.gnu.org/licenses/gpl.txt The GNU General Public License version 3
 *
 */

?>

<?php

if (!function_exists('L'))
{
	function L($name, &$_T)
	{
		return $_T->This->Language($name);
	}
}

$_T = &$_Template;
$_Tpl = &$_T->GetTemplates();
$_Tpl->Template('Header.tpl.php')->Assign(array('Title' => L('GStats++ 3 - Installation Step 2', $_T)))->Display();

$Uri = $_SERVER['REQUEST_URI'];
$Pos = strpos($Uri, '?');

if ($Pos != false)
{
	$Uri = substr($Uri, 0, $Pos);
}

$Pos = strrpos($Uri, '/');

$Uri = substr($Uri, 0, $Pos + 1);

$FullUrl = $Uri . 'Medias/GStatspp/Default/Install/';

?>

			<div id="Header">

				<div id="HeaderTop">
					<img src="<?=$FullUrl?>Header.png" alt="GStats++" />
				</div>

				<div id="HeaderSteps">
					<span class="NotSelected"><?=L('Step 1 (Agreement)', $_T)?></span> <img src="<?=$FullUrl?>Arrow.png" alt="->" />
					<span class="Selected"><?=L('Step 2 (Environment check)', $_T)?></span> <img src="<?=$FullUrl?>Arrow.png" alt="->" />
					<span class="NotSelected"><?=L('Step 3 (Configuration)', $_T)?></span> <img src="<?=$FullUrl?>Arrow.png" alt="->" />
					<span class="NotSelected"><?=L('Step 4 (Installation)', $_T)?></span>
				</div>

			</div>

			<div id="Content">
				<div id="ContentH1">
					<div id="ContentH2">
						<div class="Content">

							<h1><?=L('GStats++ 3 Installation', $_T)?></h1>

							<h2><?=L('Step 2 (Environment check)', $_T)?></h2>

							<p><?=L('The script will now proceed to check if the environment is suitable to continue the installation of GStats++.', $_T)?></p>

							<p>&nbsp;</p>

							<table class="EnvironmentCheck" cellpadding="0" cellspacing="0">

								<thead>
									<th width="40%"><?=L('Name', $_T)?></th>
									<th width="15%"><?=L('Recommended', $_T)?></th>
									<th width="15%"><?=L('Minimal', $_T)?></th>
									<th witdh="15%"><?=L('Status', $_T)?></th>
									<th width="15%"></th>
								</thead>

<?php

$c_Tests = count($_Template->Tests);
$Tests_keys = array_keys($_Template->Tests);

for($i = 0; $i < $c_Tests; $i++)
{
	echo '<tr>
		<th class="Name">' . $Tests_keys[$i] . '</th>';

	if (isset($_Template->Tests[$Tests_keys[$i]][1]) && isset($_Template->Tests[$Tests_keys[$i]][2]) && isset($_Template->Tests[$Tests_keys[$i]][3]))
	{
		echo '<td>' . $_Template->Tests[$Tests_keys[$i]][1] . '</td>';
		echo '<td>' . $_Template->Tests[$Tests_keys[$i]][2] . '</td>';
		echo '<td>' . $_Template->Tests[$Tests_keys[$i]][3] . '</td>';
		echo '<td><img src="' . $FullUrl . ($_Template->Tests[$Tests_keys[$i]][0] == CHECK_ERROR ? 'Cross.png' : ($_Template->Tests[$Tests_keys[$i]][0] == CHECK_WARNING ? 'Warning.png' : 'Check.png')) . '" tag="" /></td>';
	}
	else
	{
		echo '<td colspan="4"><img src="' . $FullUrl . ($_Template->Tests[$Tests_keys[$i]][0] == CHECK_ERROR ? 'Cross.png' : ($_Template->Tests[$Tests_keys[$i]][0] == CHECK_WARNING ? 'Warning.png' : 'Check.png')) . '" tag="" /></td>';
	}

	echo '</tr>';
}

?>

							</table>

<?php

$n_Messages = 0;
for($i = 0; $i < $c_Tests; $i++)
{
	if (isset($_T->TestsMessages[$Tests_keys[$i]]) && $_T->TestsMessages[$Tests_keys[$i]] != null)
	{
		if ($n_Messages == 0)
		{
			echo '<p>&nbsp;</p><table class="EnvironmentCheck" cellpadding="0" cellspacing="0">
				<thead>
					<th width="15%">' . L('Status', $_T) . '</th>
					<th width="30%">' . L('Name', $_T) . '</th>
					<th width="55%">' . L('Message', $_T) . '</th>
				</thead>';
		}

		echo '<tr>
		<td><img src="' . $FullUrl . ($_Template->Tests[$Tests_keys[$i]][0] == CHECK_ERROR ? 'Cross.png' : ($_Template->Tests[$Tests_keys[$i]][0] == CHECK_WARNING ? 'Warning.png' : 'Check.png')) . '" tag="" /></td>
		<th class="Name">' . $Tests_keys[$i] . '</th>
		<td>' . $_T->TestsMessages[$Tests_keys[$i]] . '</td>
		</tr>';

		$n_Messages++;
	}
}

if ($n_Messages > 0)
{
	echo '</table>';
}

?>

							<p>&nbsp;</p>

<?php

if ($_T->Continue)
{

?>

							<form action="?GStatsppInstall/<?=$_T->This->GetLanguage()?>/Step3" method="POST">
							<p style="text-align: center;">

								<br /><br />
								<input type="submit" value="<?=L('Continue to step 3.', $_T)?>" name="submit" />

							</p>
							</form>

<?php

}
else
{

?>
							
							<form action="?GStatsppInstall/<?=$_T->This->GetLanguage()?>/Step2" method="POST">
							<p style="text-align: center;">

								<br /><br />
								<input type="submit" value="<?=L('Retry', $_T)?>" name="submit" />

							</p>
							</form>

<?php

}

?>

						</div>
					</div>
					<div id="ContentBottom"></div>
				</div>
			</div>

<?php

$_Tpl->Template('Footer.tpl.php')->Display();

?>